#include "user_lvgl.h"
#ifdef LVGL_PRINTF_ON
lv_obj_t *__printf_label;
#endif
static void LVGL_PrintLabel(void);
static lv_obj_t *img;
void LVGL_Init(void) {
    lv_init();
    lv_port_disp_init();
    //lv_port_fs_init();
    lv_extra_init();
    LVGL_CreateImg(0, 0);
#ifdef LVGL_PRINTF_ON
    LVGL_PrintLabel();
#endif
}

static void LVGL_PrintLabel(void) {
    __printf_label = lv_label_create(lv_scr_act());
    lv_label_set_long_mode(__printf_label, LV_LABEL_LONG_WRAP);
    lv_obj_set_pos(__printf_label, 0, 10);
    lv_label_set_text(__printf_label, "lvgl printf string ");
}

void LVGL_CreateImg(int16_t X, int16_t Y) {
    img = lv_img_create(lv_scr_act());
    lv_img_set_src(img,"0:/ImageBin/AZ0001.bin");
    lv_img_set_angle(img, 0);
    lv_obj_set_pos(img, X, Y);
    lv_obj_center(img);
}
void LVGL_ImgSrc(char* src){
    lv_img_set_src(img,src);
}

void LVGL_CreateLabel(int16_t X, int16_t Y) {
    lv_obj_t *label = lv_label_create(lv_scr_act());
    lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
    lv_obj_set_pos(label, X, Y);
    lv_label_set_text(label, "HELLOWORLD ");
}